import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Resolve } from '@angular/router';

@Injectable({
	providedIn: 'root',
})
export class DashboardService implements Resolve<{ count: Count; exception: any }> {
	constructor(private http: HttpClient) {}
	async resolve() {
		const count = await this.statistics();
		const exception = await this.exception();
		return { count, exception };
	}

	statistics() {
		return this.http.get<Count>('/api/admin/area_statistics').toPromise();
	}

	exception() {

		// let res=this.http.get<ExceptionCount[]>('/api/admin/statistic/exception/pc?days=15').toPromise();
		let res=new Promise((resolve)=>{
			resolve([])
		})
		// console.log('resssssssss:',res)
		return res
	}
}

export interface Count {
	area_count: number;
	new_area_count: number;
	user_count: number;
	new_user_count: number;
	pc_count: number;
	new_pc_count: number;
	software_count: number;
	new_software_count: number;
}
export interface ExceptionCount {
	os: number;
	software: number;
	date: Date;
}
